<?php
  /**
   * Elgg europass : Europass content iFrame View
   * 
   * @package ElggEuropass
   * @link http://e-portfolio.uvsq.fr/
   */

  $config = find_plugin_settings('europass');
  
  $url = 'https://europass.cedefop.europa.eu/instruments/cv/xmlPostUpload.do';
  echo '<form id="euroform" action="' . $url
    . '" method="post" target="euroframe">';
  
  if(!empty($vars['europass'])) {
    $file = new ElggFile($vars['europass']->file);
    echo '<textarea name="EUROPASSCV" id="EUROPASSCV">'
      . $file->grabFile() .'</textarea>';
    echo '<input type="hidden" value="' . $vars['url']
      . 'action/europass/edit?guid='.$vars['europass']->getGUID()
      . '" name="submitURL" id="submitURL" />';
  }
  else {
    echo '<textarea name="EUROPASSCV" id="EUROPASSCV"></textarea>';
    echo '<input type="hidden" value="' . $vars['url']
      . 'action/europass/add" name="submitURL" id="submitURL" />';
  }
  
  echo '<input type="hidden" value="' . $config->locale
    . '" name="locale" id="locale" />';
  echo '<input type="hidden" value="' . $config->authId
    . '" name="authId" id="authId" />';
  echo '<input type="submit" value="OK" />';
  echo '</form>';
  echo '<iframe class="europass" name="euroframe" frameborder="0"></iframe>';
?>

<script type="text/javascript">
  $(document).ready(function() {
    $('#euroform').submit().hide();
  });
</script>